//
//  ZGPieChartViewController.m
//  扫码
//
//  Created by 鲍志刚 on 16/4/21.
//  Copyright © 2016年 鲍志刚. All rights reserved.
//

#import "ZGPieChartViewController.h"
#import "ZGView.h"
#import "ZFChart.h"
#import "ZGStatisticsData.h"

@interface ZGPieChartViewController ()<ZFPieChartDataSource>

@property (nonatomic, strong) NSArray *intervalDate;

@property (nonatomic, strong) NSArray *data;

@property (nonatomic, assign, getter = isCode) BOOL code;

@end

@implementation ZGPieChartViewController

-(NSArray *)intervalDate {
    
    if (_intervalDate == nil) {
        
        _intervalDate = [NSArray array];
        
    }
    
    return _intervalDate;
    
}

- (NSArray *)data {
    
    if (_data == nil) {
        
        _data = [NSArray array];
        
    }
    
    return  _data;
}

-(void)setStatisticData:(ZGStatisticsData *)statisticData {
    
    _statisticData = statisticData;
    
    self.intervalDate = statisticData.intervalDate;
    
    self.data = statisticData.data;
    
    NSLog(@"data:%@,intervalDate:%@ ",self.data,self.intervalDate);
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    ZFPieChart * pieChart = [[ZFPieChart alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - NAVIGATIONBAR_HEIGHT)];
    pieChart.dataSource = self;
    //    pieChart.piePatternType = kPieChartPatternTypeForCircle;
    //    pieChart.percentType = kPercentTypeInteger;
    //    pieChart.isShadow = NO;
    pieChart.isShowDetail = YES;
    pieChart.topic = @"扫码人数统计";
    [pieChart strokePath];
    [self.view addSubview:pieChart];
    
  /*  [ZGStatisticsData statisticsDataWithURL:@"SweepServlet?method=getSaveCount&startTime=2016-04-01&endTime=2016-04-07" successBlock:^(NSDictionary *dict) {
        
        ZGStatisticsData *statistic = [[ZGStatisticsData alloc] initWithDict:dict];
        
        
        
        self.data = dict[@"data"];
        self.intervalDate = dict[@"intervalDate"];
        
        self.data = statistic.data;
        
        self.intervalDate = statistic.intervalDate;
        
        [pieChart strokePath];
        //
    } errorBlock:^(NSError *e) {
        
    }];
   
   */
   
    
//    self.view = [[ZGView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
}

#pragma mark - ZFPieChartDataSource

- (NSArray *)valueArrayInPieChart:(ZFPieChart *)chart{
    return @[@"3", @"15", @"8", @"0", @"0", @"0",@"7"];
    
    /*
     {"intervalDate":["2016-04-07","2016-04-06","2016-04-05","2016-04-04","2016-04-03","2016-04-02","2016-04-01"],"data":[3,15,8,0,0,0,7],"code":"true"}
     */
//    NSMutableArray *mArray = [NSMutableArray array];
//    
//    for (int i = 0; i < self.data.count; i++) {
//        
//        NSString *str = [NSString stringWithFormat:@"%@",self.data[i]];
//        
//        [mArray addObject:str];
//    }
//    
//    
//    return mArray.copy;
}

- (NSArray *)nameArrayInPieChart:(ZFPieChart *)chart{
    return @[@"16-04-01", @"16-04-02", @"16-04-03", @"16-04-04", @"16-04-05", @"16-04-06",@"16-04-07"];
//    return self.intervalDate;
}

- (NSArray *)colorArrayInPieChart:(ZFPieChart *)chart{
    return @[ZFColor(71, 204, 255, 1), ZFColor(253, 203, 76, 1), ZFColor(214, 205, 153, 1), ZFColor(78, 250, 188, 1), ZFColor(16, 140, 39, 1), ZFColor(45, 92, 34, 1),ZFColor(0, 0, 0, 1)];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
